package com.lening.communitylog.controller;


import com.lening.common.base.BaseController;
import com.lening.common.web.Result;
import com.lening.communitylog.dto.LogDto;
import com.lening.communitylog.pojo.Log;
import com.lening.communitylog.service.LogService;
import com.lening.communitylog.vo.LogVo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 操作日志表 前端控制器
 * </p>
 *
 * @author 秦旭
 * @since 2024-06-04
 */
@RestController
@RequestMapping("log")
public class LogController extends BaseController<Log, LogDto, LogService> {


    @Autowired(required = false)
    private LogService logService;

//    @Autowired(required = false)
//    private RedisService redisService;
//
//    @GetMapping("/getTotalCounts")
//    public Result<?> getTotalCounts(@RequestParam List<String> tableNames){
//
//        redisService.save("counts", String.valueOf(logService.getTotalCounts(tableNames)));
//        return Result.ok(logService.getTotalCounts(tableNames));
//    }

    @PostMapping("addLog")
    public Result<?> addLog(@RequestBody LogVo logVo){

        logService.addLog(logVo);
        return Result.ok();
    }

    @GetMapping("getTableNamePage")
    public Result<?> getTableNamePage(){

        List<String> tableNamePage = logService.getTableNamePage();
        return Result.ok(tableNamePage);
    }
}
